/**
 * Create in 2012-4-23.
 */
package kit4j.ui.cs.swing.component;

import java.awt.Point;

import javax.swing.JMenu;
import javax.swing.SwingConstants;


/**
 * 菜单位置设定器类型。
 * 
 * @author MiniKnife
 * 
 */
public abstract class MenuLocator implements SwingConstants {

	/**
	 * 创建指定的菜单组件与定位属性的弹出菜单位置设定器。
	 * 
	 * @param menu
	 *            菜单组件
	 * @param location
	 *            定位属性
	 * @return 菜单位置设定器
	 */
	public static MenuLocator getMenuLocator(JMenu menu, int location) {
		switch (location) {
		case NORTH:
			return new NorthMenu(menu);
		case NORTH_WEST:
			return new NorthWestMenu(menu);
		case NORTH_EAST:
			return new NorthEastMenu(menu);
		case WEST:
			return new WestMenu(menu);
		case SOUTH:
			return new SouthMenu(menu);
		case SOUTH_WEST:
			return new SouthWestMenu(menu);
		case SOUTH_EAST:
			return new SouthEastMenu(menu);
		case EAST:
			return new EastMenu(menu);
		default:
			throw new IllegalArgumentException("location: " + location);
		}
	}

	/**
	 * @return 弹出菜单的原点位置。
	 */
	abstract public Point getMenuOrigin();
}
